package com.wms.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wms.bean.PageBean;
import com.wms.dto.StoreLocationDto;
import com.wms.entity.StoreLocation;
import com.wms.mapper.StoreLocationMapper;
import com.wms.service.StoreLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

@Service
public class StoreLocationServiceImpl implements StoreLocationService {

    @Autowired
    StoreLocationMapper storeLocationMapper;
    @Override
    public PageBean queryList(@RequestBody StoreLocationDto storeLocationDto) {
        PageHelper.startPage(storeLocationDto.getPage(),storeLocationDto.getPageSize());
        List<Map> list=storeLocationMapper.selectAll(storeLocationDto);
        PageInfo info=new PageInfo(list);
        return new PageBean(storeLocationDto.getPage(),storeLocationDto.getPageSize(),info.getTotal(),list);
    }

    @Transactional
    @Override
    public int addStoreLocation(StoreLocation storeLocation) {
        return storeLocationMapper.insertStoreLocation(storeLocation);
    }

    @Override
    public int removeById(int id) {
        return storeLocationMapper.deleteById(id);
    }

    @Override
    public int changeStoreLocation(StoreLocation storeLocation) {
        return storeLocationMapper.updateStoreLocation(storeLocation);
    }

    @Override
    public int deleteSome(List<Integer> ids) {
        return storeLocationMapper.deleteSome(ids);
    }
}
